home *** CD-ROM | disk | FTP | other *** search
/ .net (French) 1996 December / .net Magazine (FR) - Issue 02 - Dec 1996.iso / Utilpers / SUPERQUE / DATA.2 / FILTERS / PSINIT / GS_BTOKN.PS < prev    next >
Text File  |  1995-11-15  |  9KB  |  270 lines

  1. %    Copyright (C) 1994, 1995 Aladdin Enterprises.  All rights reserved.
  2. %    Licensed to Zenographics Inc. (Irvine, California) by Artifex Software Inc.
  3. %    under the OEM Agreement of December 21st, 1993.
  4.  
  5. % Initialization file for binary tokens.
  6. % When this is run, systemdict is still writable,
  7. % but everything defined here goes into level2dict.
  8.  
  9. % Define whether or not to allow writing dictionaries.
  10. /WRITEDICTS true def
  11.  
  12. languagelevel 1 .setlanguagelevel
  13. level2dict begin
  14.  
  15. % Initialization for the system name table.
  16.  
  17. mark
  18. % 0
  19.     /abs /add /aload /anchorsearch /and
  20.     /arc /arcn /arct /arcto /array
  21.     /ashow /astore /awidthshow /begin /bind
  22.     /bitshift /ceiling /charpath /clear /cleartomark
  23. % 20
  24.     /clip /clippath /closepath /concat /concatmatrix
  25.     /copy /count /counttomark /currentcmykcolor /currentdash
  26.     /currentdict /currentfile /currentfont /currentgray /currentgstate
  27.     /currenthsbcolor /currentlinecap /currentlinejoin /currentlinewidth /currentmatrix
  28. % 40
  29.     /currentpoint /currentrgbcolor /currentshared /curveto /cvi
  30.     /cvlit /cvn /cvr /cvrs /cvs
  31.     /cvx /def /defineusername /dict /div
  32.     /dtransform /dup /end /eoclip /eofill
  33. % 60
  34.     /eoviewclip /eq /exch /exec /exit
  35.     /file /fill /findfont /flattenpath /floor
  36.     /flush /flushfile /for /forall /ge
  37.     /get /getinterval /grestore /gsave /gstate
  38. % 80
  39.     /gt /identmatrix /idiv /idtransform /if
  40.     /ifelse /image /imagemask /index /ineofill
  41.     /infill /initviewclip /inueofill /inufill /invertmatrix
  42.     /itransform /known /le /length /lineto
  43. % 100
  44.     /load /loop /lt /makefont /matrix
  45.     /maxlength /mod /moveto /mul /ne
  46.     /neg /newpath /not /null /or
  47.     /pathbbox /pathforall /pop /print /printobject
  48. % 120
  49.     /put /putinterval /rcurveto /read /readhexstring
  50.     /readline /readstring /rectclip /rectfill /rectstroke
  51.     /rectviewclip /repeat /restore /rlineto /rmoveto
  52.     /roll /rotate /round /save /scale
  53. % 140
  54.     /scalefont /search /selectfont /setbbox /setcachedevice
  55.     /setcachedevice2 /setcharwidth /setcmykcolor /setdash /setfont
  56.     /setgray /setgstate /sethsbcolor /setlinecap /setlinejoin
  57.     /setlinewidth /setmatrix /setrgbcolor /setshared /shareddict
  58. % 160
  59.     /show /showpage /stop /stopped /store
  60.     /string /stringwidth /stroke /strokepath /sub
  61.     /systemdict /token /transform /translate /truncate
  62.     /type /uappend /ucache /ueofill /ufill
  63. % 180
  64.     /undef /upath /userdict /ustroke /viewclip
  65.     /viewclippath /where /widthshow /write /writehexstring
  66.     /writeobject /writestring /wtranslation /xor /xshow
  67.     /xyshow /yshow /FontDirectory /SharedFontDirectory /Courier
  68. % 200
  69.     /Courier-Bold /Courier-BoldOblique /Courier-Oblique /Helvetica /Helvetica-Bold
  70.     /Helvetica-BoldOblique /Helvetica-Oblique /Symbol /Times-Bold /Times-BoldItalic
  71.     /Times-Italic /Times-Roman /execuserobject /currentcolor /currentcolorspace
  72.     /currentglobal /execform /filter /findresource /globaldict
  73. % 220
  74.     /makepattern /setcolor /setcolorspace /setglobal /setpagedevice
  75.     /setpattern
  76. % pad to 256
  77.     counttomark 256 exch sub { 0 } repeat
  78. % 256
  79.     /= /== /ISOLatin1Encoding /StandardEncoding
  80. % 260
  81.     /[ /] /atan /banddevice /bytesavailable
  82.     /cachestatus /closefile /colorimage /condition /copypage
  83.     /cos /countdictstack /countexecstack /cshow /currentblackgeneration
  84.     /currentcacheparams /currentcolorscreen /currentcolortransfer /currentcontext /currentflat
  85. % 280
  86.     /currenthalftone /currenthalftonephase /currentmiterlimit /currentobjectformat /currentpacking
  87.     /currentscreen /currentstrokeadjust /currenttransfer /currentundercolorremoval /defaultmatrix
  88.     /definefont /deletefile /detach /deviceinfo /dictstack
  89.     /echo /erasepage /errordict /execstack /executeonly
  90. % 300
  91.     /exp /false /filenameforall /fileposition /fork
  92.     /framedevice /grestoreall /handleerror /initclip /initgraphics
  93.     /initmatrix /instroke /inustroke /join /kshow
  94.     /ln /lock /log /mark /monitor
  95. % 320
  96.     /noaccess /notify /nulldevice /packedarray /quit
  97.     /rand /rcheck /readonly /realtime /renamefile
  98.     /renderbands /resetfile /reversepath /rootfont /rrand
  99.     /run /scheck /setblackgeneration /setcachelimit /setcacheparams
  100. % 340
  101.     /setcolorscreen /setcolortransfer /setfileposition /setflat /sethalftone
  102.     /sethalftonephase /setmiterlimit /setobjectformat /setpacking /setscreen
  103.     /setstrokeadjust /settransfer /setucacheparams /setundercolorremoval /sin
  104.     /sqrt /srand /stack /status /statusdict
  105. % 360
  106.     /true /ucachestatus /undefinefont /usertime /ustrokepath
  107.     /version /vmreclaim /vmstatus /wait /wcheck
  108.     /xcheck /yield /defineuserobject /undefineuserobject /UserObjects
  109.     /cleardictstack
  110. % 376
  111.     /A /B /C /D /E /F /G /H /I /J /K /L /M
  112.     /N /O /P /Q /R /S /T /U /V /W /X /Y /Z
  113.     /a /b /c /d /e /f /g /h /i /j /k /l /m
  114.     /n /o /p /q /r /s /t /u /v /w /x /y /z
  115. % 428
  116.     /setvmthreshold (<<) cvn
  117.     (>>) cvn /currentcolorrendering /currentdevparams /currentoverprint /currentpagedevice
  118.     /currentsystemparams /currentuserparams /defineresource /findencoding /gcheck
  119. % 440
  120.     /glyphshow /languagelevel /product /pstack /resourceforall
  121.     /resourcestatus /revision /serialnumber /setcolorrendering /setdevparams
  122.     /setoverprint /setsystemparams /setuserparams /startjob /undefineresource
  123.     /GlobalFontDirectory /ASCII85Decode /ASCII85Encode /ASCIIHexDecode /ASCIIHexEncode
  124. % 460
  125.     /CCITTFaxDecode /CCITTFaxEncode /DCTDecode /DCTEncode /LZWDecode
  126.     /LZWEncode /NullEncode /RunLengthDecode /RunLengthEncode /SubFileDecode
  127.     /CIEBasedA /CIEBasedABC /DeviceCMYK /DeviceGray /DeviceRGB
  128.     /Indexed /Pattern /Separation
  129. % 478 -- end
  130. .packtomark
  131.  
  132. % Install the system and user name tables.
  133. % The user name table is read-only for ordinary programs,
  134. % since it doesn't obey save/restore and must be managed specially.
  135.  
  136. dup /SystemNames exch def
  137. 100 array readonly dup /UserNames exch def
  138. .installnames
  139.  
  140. % Define printobject and writeobject.
  141. % These are mostly implemented in PostScript, so that we don't have to
  142. % worry about interrupts or callbacks when writing to the output file.
  143.  
  144. % Define procedures for accumulating the space required to represent
  145. % an object in binary form.
  146. /cntdict mark        % <#refs> <#chars> <obj> -proc- <#refs> <#chars>
  147.     /integertype /pop load
  148.     /realtype 1 index
  149.     /marktype 1 index
  150.     /nulltype 1 index
  151.     /booleantype 1 index
  152.     /nametype { length add } bind
  153.     /stringtype 1 index
  154.     /arraytype null
  155.     WRITEDICTS { /dicttype null } if
  156. .dicttomark def
  157. cntdict /arraytype
  158.  { dup dup length 5 -1 roll add 4 2 roll
  159.     { dup type //cntdict exch get exec } forall
  160.  } bind put
  161. WRITEDICTS
  162.  { cntdict /dicttype
  163.     { dup dup length 2 mul 5 -1 roll add 4 2 roll
  164.        { 4 1 roll dup type //cntdict exch get exec
  165.      3 -1 roll dup type //cntdict exch get exec
  166.        } forall
  167.     } bind put
  168.  } if
  169.  
  170. /w2dict mark
  171.     /nametype { 2 copy .writecvs pop } bind
  172.     /stringtype 1 index
  173. .dicttomark def
  174.  
  175. /.writeobjects        % <file> <tag> <array> .writeobjects -
  176.  {
  177.     mark exch
  178.  
  179.     % Count the space required for refs and strings.
  180.     dup length 0 3 -1 roll
  181.     % Stack: <file> <tag> -mark- <#refs> <#chars> <array>
  182.  
  183.     dup 4 1 roll
  184.      { dup type //cntdict exch get exec
  185.      } forall
  186.  
  187.     % Write the header.
  188.     % Stack: <file> <tag> -mark- <array1> ... <array|dictN> <#refs> <#chars>
  189.     counttomark 3 add -2 roll 4 1 roll
  190.     % Stack: -mark- <array1> ... <array|dictN> <tag> <#refs> <#chars> <file>
  191.     dup counttomark 1 sub index length
  192.     4 index 3 bitshift 4 index add
  193.     (xxxxxxxx) .bosheader writestring
  194.  
  195.     % Write the objects per se.
  196.     3 1 roll pop
  197.     counttomark 1 sub index length 3 bitshift exch
  198.     3 bitshift
  199.     % Stack: -mark- <array1> ... <array|dictN> <tag> <file> <ref#> <char#>
  200.  
  201.     counttomark 4 sub
  202.      { counttomark -1 roll dup 6 1 roll
  203.        dup type /dicttype eq        % can't be first object
  204.         {  { 5 1 roll (xxxxxxxx) .bosobject
  205.          3 index exch writestring
  206.          4 -1 roll (xxxxxxxx) .bosobject
  207.          3 index exch writestring
  208.            } forall
  209.         }
  210.         {  { (xxxxxxxx) .bosobject
  211.          dup 1 6 index put
  212.          3 index exch writestring
  213.          4 -1 roll pop 0 4 1 roll    % clear tag
  214.            } forall
  215.         }
  216.        ifelse
  217.      }
  218.     repeat
  219.  
  220.     % Write the strings and names.
  221.     pop pop exch pop
  222.     % Stack: -mark- <array1> ... <array|dictN> <file>
  223.  
  224.      counttomark 1 sub
  225.      { counttomark -1 roll
  226.         {        % The counting pass ensured that the keys and values
  227.             % of any dictionary must be writable objects.
  228.             % Hence, we are processing a dictionary iff
  229.             % the next-to-top stack element is not a file.
  230.           1 index type /filetype ne
  231.            { exch 2 index exch dup type //w2dict exch .knownget
  232.           { exec } { pop } ifelse pop
  233.            }
  234.           if
  235.               dup type //w2dict exch .knownget { exec } { pop } ifelse
  236.         } forall
  237.      }
  238.     repeat
  239.  
  240.     % Clean up.
  241.     % Stack: -mark- <file>
  242.  
  243.     pop pop
  244.  
  245.  } odef
  246. currentdict /cntdict undef
  247. currentdict /w2dict undef
  248.  
  249. /printobject { (%stdout) (w) file 3 1 roll writeobject } odef
  250. /writeobject { exch 1 array astore .writeobjects } odef
  251.  
  252. % Implement binary error message output.
  253.   /.printerror
  254.    { $error /binary get .languagelevel 2 eq and
  255.       { currentobjectformat 0 ne
  256.          { [ /Error $error /errorname get $error /command get false
  257.        ] 250 printobject
  258.      }
  259.      //.printerror
  260.     ifelse
  261.       }
  262.       //.printerror
  263.      ifelse
  264.    } bind def
  265.  
  266. % End of level2dict
  267.  
  268. end
  269. .setlanguagelevel
  270.